﻿<!--{include /service/service_head}-->





<!-- End #sidebar -->
	<div id="main-content">
		<!-- Main Content Section with everything -->
		<!-- Page Head -->
		<form action="/service/dataManageEdit.php" id="indexform" method="post">
		<div id="data_manage_edit_top">
			
			<select name="shop_id" class="small-input">
				<option value="0">選択してください</option>
				${Utility::Option(Utility::OptionArray($shopList, 'id', 'shop_name'), $defaultShopId)}
			</select>
			<select id="staff_id" name="staff_id" class="small-input">
	           	<option value="0">選択してください</option>
				${Utility::Option(Utility::OptionArray($staffList, 'id', 'family_name', 'personal_name'), $staffId)}
	        </select>
	        <select name="time_type" class="small-input">
				<option value="0">選択してください</option>
				${Utility::Option($timeTypeList, $timeType)}
			</select>
			<input type="text" name="start_date" value="${date("Y-m-d", $startTime)}" onfocus="WdatePicker({lang:'jp'})" class="Wdate"/>
			<!--{if $endTime < $startTime}-->
			<input type="text" name="end_date" value="" onfocus="WdatePicker({lang:'jp'})" class="Wdate"/>
			<!--{else}-->
			<input type="text" name="end_date" value="${date("Y-m-d", $endTime)}" onfocus="WdatePicker({lang:'jp'})" class="Wdate"/>
			<!--{/if}-->
		</div>
		
		<!-- End .clear -->

		<div class="content-box">
			<!-- Start Content Box -->
			<div class="content-box-header">
				<h3>会員別予約回数統計</h3>
				<ul class="content-box-tabs" style="display:none;">
					<li><a href="#tab1" class="default-tab">详细</a></li>
					<!-- href must be unique and match the id of target div -->
					<li><a href="#tab2">编辑</a></li>

				</ul>
				<div class="clear"></div>
			</div>
			<!-- End .content-box-header -->
			<div class="content-box-content">
				<div class="tab-content default-tab" id="tab1">
					<!-- This is the target div. id must match the href of this div's tab -->
					<div id="data_manage_edit_middle" class="table_box">
						<table>

						<thead class="title_head">
							<tr>
								<th class="title">スタッフ</th><th class="title">トータル出勤時間</th><th class="title">トータル休憩時間</th><th class="title">勤務時間</th>
								<th class="title">時給</th><th class="title">給料合計</th><th class="title">賞用</th><th class="title">交通費</th><th class="title">立替金</th>
								<th class="title">その他</th><th class="title">罰金</th><th class="title">合計</th>
							</tr>
						</thead>
						<tbody>
							<tr>
						    	<?php
									$tempStaff = Staff::getById($one1['staff_id'])
    	?>
						    	<td>
						    		<input type="hidden" name="id" value="{$one1['id']}"/>
						    		<input type="text" id="staff_name" readonly="readonly" value="{$tempStaff['family_name']} {$tempStaff['personal_name']}" size="10"/>
						    	</td>
						    	<td>
						    		<input type="text" id="tuukin_total_hour" name="tuukin_total_hour" readonly="readonly" value="{$one1['tuukin_total_hour']}" size="4"/>
						    		<input type="text" id="tuukin_total_minute" name="tuukin_total_minute" readonly="readonly" value="{$one1['tuukin_total_minute']}" size="2"/>
						    	</td>
						    	<td>
						    		<input type="text" id="rest_total_hour" name="rest_total_hour" readonly="readonly" value="{$one1['rest_total_hour']}" size="4"/>
						    		<input type="text" id="rest_total_minute" name="rest_total_minute" readonly="readonly" value="{$one1['rest_total_minute']}" size="2"/>
						    	</td>
						    	<td>
						    		<input type="text" id="work_total_hour" name="work_total_hour" readonly="readonly" value="{$one1['work_total_hour']}" size="4"/>
						    		<input type="text" id="work_total_minute" name="work_total_minute" readonly="readonly" value="{$one1['work_total_minute']}" size="2"/>
						    	</td>
						    	<td><input type="text" id="salary" name="salary" readonly="readonly" value="{$tempStaff['salary']}" size="4"/></td>
						    	<td><input type="text" id="back1" name="back1" value="{$tempStaff['back1']}" size="4"/></td>
						    	<td><input type="text" id="reword_money" name="reword_money" value="{$one1['reword_money']}" size="4"/></td>
						    	<td><input type="text" id="bus_money" name="bus_money" value="{$one1['bus_money']}" size="4"/></td>
						    	<td><input type="text" id="change_money" name="change_money" value="{$one1['change_money']}" size="4"/></td>
						    	<td><input type="text" id="other_money" name="other_money" value="{$one1['other_money']}" size="4"/></td>
						    	<td><input type="text" id="batu_money" name="batu_money" value="{$one1['batu_money']}" size="4"/></td>
						    	<td><input type="text" id="total_money" name="total_money" value="{$one1['total_money']}" size="4"/></td>
						    </tr>
							<tr><td><input type="submit" value="作成" /></td></tr>
							
						</tbody>
					</table>

					</div>
					<p class="bottom_m"><a href="{$_SERVER['HTTP_REFERER']}">戻る</a></p>
					<div style="display:none;">
					<table>
							<tr>
								<td colspan="7"><div class="pagination"> <a href="#" title="First Page">&laquo; First</a><a href="#" title="Previous Page">&laquo; Previous</a> <a href="#" class="number" title="1">1</a> <a href="#" class="number" title="2">2</a> <a href="#" class="number current" title="3">3</a> <a href="#" class="number" title="4">4</a> <a href="#" title="Next Page">Next &raquo;</a><a href="#" title="Last Page">Last &raquo;</a> </div>

									<!-- End .pagination -->
									<div class="clear"></div></td>
							</tr>
							</table>
					</div>
				</div>
			</div>
			<!-- End .content-box-content -->
		</div>

		<!-- End .content-box -->
		<!-- End .content-box -->
		<!-- End .content-box -->
		<div class="clear"></div>
		<!-- Start Notifications -->
		<!-- End Notifications -->
		<div id="footer"> <small>
			<!-- Remove this notice or replace it with whatever you want -->

			&#169; Copyright 2011 川崎エステ　エレガントリゾート　すべての女性を美しく幸せに | Powered by <a href="#">ZHONGHUA</a> | <a href="#">Top</a> </small> </div>
		<!-- End #footer -->
	</div>
	<!-- End #main-content -->
</div>

</body>
<!-- Download From www.exet.tk-->
</html>

<script type="text/javascript"><!-- 
	var tempCalendar = null;
	jQuery(function(){
		if( $("input[name='start_date']").length > 0 ){
			

			$("select[name='shop_id']").bind("change", function(){
				if( $(this).val() < 1 ){
					return ;
				}
				$.get("{$webRoot}/service/searchStaff.php", "shop_id=" + $(this).val(), function(data){
					
					var options = '<option value="0">選択してください</option>';
					if( data.error == 0 ){
						for(var index in data.data){
							if( !index ){
								continue;
							}
							options = options + '<option value="' + data.data[index].id + '">' + data.data[index].family_name + " " + data.data[index].personal_name + '</option>';
							
						}
					}
					$("#staff_id").html(options);
				}, "json");
				
			});

			$("#staff_id").bind("change", function(){
				calcWorkTime();
				getStaffById();
				
			});

			$("input[name='start_date']").bind("blur", function(e){
				calcWorkTime();
			});

			$("input[name='end_date']").bind("blur", function(e){
				calcWorkTime();
			});

			$("select[name='time_type']").bind("change", function(e){
				calcWorkTime();
			})
		}

		$("#back1").bind("change", function(e){
			calcMoney();
		})

		$("#reword_money").bind("change", function(e){
			calcMoney();
		})

		$("#bus_money").bind("change", function(e){
			calcMoney();
		})

		$("#change_money").bind("change", function(e){
			calcMoney();
		})

		$("#other_money").bind("change", function(e){
			calcMoney();
		})

		$("#batu_money").bind("change", function(e){
			calcMoney();
		})
	});

	function calcWorkTime(){
		$("input[name='end_date']").val( calcEndTime() );
		if( $("#staff_id").val() < 1 || $("input[name='start_date']").val().length < 1 || $("input[name='end_date']").val().length < 1 ){
			return ;
		}
		var data = "staff_id=" + $("#staff_id").val() + "&start_date="+ $("input[name='start_date']").val();
		data = data + "&end_date="+ $("input[name='end_date']").val();
		$.get("{$webRoot}/service/calcWorkTime.php", data, function(data){
			if( data.error == 0 ){
				$("input[name='tuukin_total_hour']").val( data.data.work_schedule_hour );
				$("input[name='tuukin_total_minute']").val( data.data.work_schedule_minute );
				$("input[name='rest_total_hour']").val( data.data.rest_hour);
				$("input[name='rest_total_minute']").val( data.data.rest_minute);
				$("input[name='work_total_hour']").val( data.data.work_hour);
				$("input[name='work_total_minute']").val( data.data.work_minute);
				$("input[name='salary']").val( data.data.salary);
				if( data.data.salary_type < 1 ){
					$("#back1").val( ( data.data.work_hour  + (data.data.work_minute / 60) )* data.data.salary);
				}else if( data.data.salary_type == 1 ){
					var monthPercent = 1;
					$("#back1").val( data.data.salary );
					/*var timeType = $("select[name='time_type']").val();
					if( timeType == 1 ){
						$("#back1").val( data.data.salary / 22 );
					}else if( timeType == 2 ){
						$("#back1").val( data.data.salary / 4 );
					}else{
						$("#back1").val( data.data.salary );
					}*/
										
				}
				calcMoney();
			}
		}, "json");
	}

	function calcMoney(){
		var back1Money = $("#back1").val() * 1;
		var rewordMoney = $("#reword_money").val() * 1;
		var busMoney = $("#bus_money").val() * 1;
		var changeMoney = $("#change_money").val() * 1;
		var otherMoney = $("#other_money").val() * 1;
		var batuMoney = $("#batu_money").val() * 1;
		$("#total_money").val( back1Money + rewordMoney + busMoney + changeMoney + otherMoney - batuMoney );
	}

	function getStaffById(){
		if( $("#staff_id").val() < 1 ){
			return ;
		}
		$.get("{$webRoot}/service/searchStaffById.php", "staff_id=" + $("#staff_id").val(), function(data){
			
			if( data.error == 0 ){
				$("#staff_name").val( data.data['family_name'] + " " + data.data['personal_name'] );
			}
		}, "json");
	}

	/*function  getDaydiff(d1, d2){  
	     var  arrDate,strDate,arrDate2,strDate2,diffDays
	     arrDate= d1.split("-")  
	     strDate=new  Date(arrDate[1]  +  '-'  +  arrDate[2]  +  '-'  +  arrDate[0])    //转换为12-18-2002格式  
	     arrDate2=d2.split("-")  
	     strDate2= new  Date(arrDate2[1]  +  '-'  +  arrDate2[2]  +  '-'  +  arrDate2[0])  
	     diffDays = parseInt(Math.abs(strDate2-strDate)  /  1000  /  60  /  60  /24)    //把相差的毫秒数转换为天数  
	     return diffDays; 
	}*/

	function calcEndTime(){
		var strStartDate = $("input[name='start_date']").val();
		if( strStartDate.length < 1 ){
			return "";
		}
		var arrDate= strStartDate.split("-");
		var timeType = $("select[name='time_type']").val();
		if( arrDate.length < 3 || timeType < 1 ){
			return "";
		}
		arrDate[1] = arrDate[1] - 1; 
		var startDate = new Date();
		startDate.setFullYear(arrDate[0], arrDate[1], arrDate[2]);
		var endDate = new Date();
		var timeType = $("select[name='time_type']").val();
		if( timeType == 1 ){
			return strStartDate;
		}else if( timeType == 2 ){
			endDate.setFullYear(arrDate[0], arrDate[1], arrDate[2] * 1 + 6);
		}else if( timeType == 3 ){
			endDate.setFullYear(arrDate[0], arrDate[1]*1 + 1, arrDate[2] - 1);
		}
		return endDate.getFullYear() + "-" + (endDate.getMonth() * 1 + 1) + "-" + endDate.getDate();
	}
</script> 
</html> 